home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-03-25 | 5.7 KB | 242 lines | [TEXT/KAHL] |
- /******************************************************************************
- CAboutBox.c
-
- The AboutBox Class
-
- SUPERCLASS = CDirector
-
- Copyright © 1989 Symantec Corporation. All rights reserved.
-
- TCL 1.1.3 Changes:
- [
- - A stray deactivate event appeared to be left on the queue after this
- class is disposed; CurDeactive is set to NULL at the end of Dispose.
- ]
- TCL 2.0 Changes:
- [
- - Replaced IAboutBox and Dispose with contructor and destructor.
- ]
- ******************************************************************************/
-
- #include "Global.h"
- #include "OSChecks.h"
- #include "CDesktop.h"
- #include "CDecorator.h"
- #include "CWindow.h"
- #include "CPicture.h"
- #include "CAboutBox.h"
- #include "CApplication.h"
- #include <LoMem.h>
-
- /*** Global Variables ***/
-
- extern CDesktop *gDesktop; /* The visible Desktop */
- extern CDecorator *gDecorator; /* Decorator for arranging windows */
-
- /*** Class Constants ***/
-
- #define WIND_ABOUT 2000
-
- typedef struct {
- SignedByte h;
- SignedByte v;
- } BytePoint;
-
- /**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
-
-
- /******************************************************************************
- IAboutBox
-
- Initialize an AboutBox object
- ******************************************************************************/
-
- CAboutBox::CAboutBox(CApplication *itsSupervisor) : CDirector(itsSupervisor)
- {
- TRY
- {
- itsWindow = new CWindow(WIND_ABOUT, TRUE, this); // KI 2/13/94
-
- gDecorator->CenterWindow(itsWindow);
-
- blackboard = GetPicture(2000); /* Load in resources */
- flatEraser = GetPicture(2001);
- rightEraser = GetPicture(2002);
- leftEraser = GetPicture(2003);
- wink = GetPicture(2004);
- acHVof = GetResource('HVof', 1);
- ghdHVof = GetResource('HVof', 2);
-
- Display();
- }
- CATCH
- {
- delete this;
- }
- ENDTRY;
- }
-
-
- /******************************************************************************
- ~AboutBox {OVERRIDE}
-
- Dispose of AboutBox by releasing all its resources
- ******************************************************************************/
-
- CAboutBox::~CAboutBox()
- {
- TCLForgetResource( blackboard);
- TCLForgetResource( flatEraser);
- TCLForgetResource( rightEraser);
- TCLForgetResource( leftEraser);
- TCLForgetResource( wink);
- TCLForgetResource( acHVof);
- TCLForgetResource( ghdHVof);
-
- // CDirector::~CDirector(); // removed for PowerPC
- // CurDeactive = NULL; // TCL 1.1.3 3/11/93 MER; stray pending deactivate event
- }
-
-
- /******************************************************************************
- Display
-
- Display contents of About Box. There's a lot a ugly code here and
- hard-wired values.
- ******************************************************************************/
-
- /*
- * Kill time for the specified duration, in ticks.
- * Exit early if the mouse is clicked or a key is pressed.
- */
-
- static Boolean MouseOrKey(
- long duration)
- {
- long startTicks;
- KeyMap macKeyMap;
-
- startTicks = TickCount();
-
- while ((TickCount() - startTicks) < duration) {
- GetKeys( macKeyMap);
-
- macKeyMap[1] &= 0xFFFFFFFD; /* Mask out Caps Lock */
- macKeyMap[3] &= 0xFFFFFF7F; /* Mask out Reset key */
-
- if ( Button() ||
- (macKeyMap[0] != 0) ||
- (macKeyMap[1] != 0) ||
- (macKeyMap[2] != 0) ||
- (macKeyMap[3] != 0) ) {
-
- return(TRUE);
- }
- }
-
- return(FALSE);
- }
-
- void CAboutBox::Display()
- {
- Rect fBlackboard;
- Rect fFlatEraser;
- Rect fRightEraser;
- Rect fLeftEraser;
- Rect fWink;
- Rect eraseClip;
- register Rect *r;
- Rect theRect;
- register short i;
- short n;
- Handle theHVof;
- register BytePoint **off;
- RGBColor chalkColor;
-
- itsWindow->Select();
- itsWindow->Prepare();
- SetOrigin(-12, -12);
-
- fBlackboard = (**blackboard).picFrame;
- fFlatEraser = (**flatEraser).picFrame;
- OffsetRect(&fFlatEraser, 250, 142);
- fRightEraser = (**rightEraser).picFrame;
- fLeftEraser = (**leftEraser).picFrame;
- fWink = (**wink).picFrame;
- OffsetRect(&fWink, 51, 111);
-
- r = &theRect;
-
- DrawPicture(blackboard, &fBlackboard);
- DrawPicture(flatEraser, &fFlatEraser);
- SetRect(&eraseClip, 72, 32, 288, 108);
-
- if (ColorQDIsPresent()) {
- chalkColor.red = 65281;
- chalkColor.green = 65281;
- chalkColor.blue = 52225;
- RGBForeColor(&chalkColor);
- RGBBackColor(&chalkColor);
- } else {
- ForeColor(whiteColor);
- }
-
- while (TRUE) {
- if (MouseOrKey(20L)) return;
-
- SetRect(r, 80, 40, 82, 42);
- n = (short) GetHandleSize(acHVof) / sizeof(BytePoint);
- off = (BytePoint**)(acHVof);
-
- for (i = 0; i < n; i++) {
- OffsetRect(r, (*off)[i].h, (*off)[i].v);
- PaintRect(r);
- if (MouseOrKey(2L)) return;
- }
-
- // Start Erasing "Art Class"
-
- if (MouseOrKey(60L)) return;
- ClipRect(&fFlatEraser);
- DrawPicture(blackboard, &fBlackboard);
- if (MouseOrKey(30L)) return;
-
- ClipRect(&fBlackboard);
- OffsetRect(&fRightEraser, 60 - fRightEraser.left,
- 12 - fRightEraser.top);
- DrawPicture(rightEraser, &fRightEraser);
-
- for (i = 0; i < 65; i++) {
- OffsetRect(&fRightEraser, 3, 1);
- DrawPicture(rightEraser, &fRightEraser);
- if (MouseOrKey(1L)) return;
- }
-
- for (i = 0; i < 9; i++) {
- OffsetRect(&fRightEraser, 0, 3);
- DrawPicture(rightEraser, &fRightEraser);
- if (MouseOrKey(1L)) return;
- }
-
- fLeftEraser = fRightEraser;
- DrawPicture(leftEraser, &fLeftEraser);
- for (i = 0; i < 65; i++) {
- OffsetRect(&fLeftEraser, -3, -1);
- DrawPicture(leftEraser, &fLeftEraser);
- if (MouseOrKey(1L)) return;
- }
-
- ClipRect(&fLeftEraser);
- DrawPicture(blackboard, &fBlackboard);
- if (MouseOrKey(30L)) return;
- ClipRect(&fBlackboard);
- DrawPicture(flatEraser, &fFlatEraser);
- if (MouseOrKey(30L)) return;
-
- n = (short) GetHandleSize(ghdHVof) / sizeof(BytePoint);
- off = (BytePoint**)(ghdHVof);
-
- // End erasing "Art Class"
- }
- }
-